﻿var ScrambledEggs;
(function (ScrambledEggs) {
    (function (Modules) {
        var BabyFinale = (function () {
            function BabyFinale() {
                this._standingUp = false;
                this._grew = false;
            }
            BabyFinale.prototype.initialize = function (gameState, onUpdate) {
                var me = this;
                var finale = $("#babyfinale");
                var play = $("#play");
                me._onUpdate = onUpdate;
                finale.find("button").not(".continue").click(function () {
                    delete gameState.State.Temporary["statsToDistribute"];
                    switch($(this).attr("class")) {
                        case "diapercat":
                            play.find(".baby").hide();
                            play.find(".catstains").show();
                            gameState.State.Message = "The Cat <i>=°ᴥ°=</i> yelps <strong>LOUDLY</strong> at this offence!";
                            gameState.State.DecisionBabyFinale = ScrambledEggs.BabyFinaleDecision.Poopcat;
                            break;
                        case "bangdoor":
                            play.find(".doorsound").show();
                            gameState.State.Message = "You bang the door <strong>LOUDLY</strong> in your fury.";
                            gameState.State.DecisionBabyFinale = ScrambledEggs.BabyFinaleDecision.Doorbang;
                            break;
                        case "settledown":
                            play.find(".baby").hide();
                            play.find(".catpurr").show();
                            gameState.State.Message = "You settle down and pet The Cat <i>=°ᴥ°=</i>.";
                            gameState.State.DecisionBabyFinale = ScrambledEggs.BabyFinaleDecision.Petcat;
                            break;
                        case "extra":
                            play.find(".baby").hide();
                            play.find(".door").animate({
                                marginLeft: "-200px"
                            }, 3000);
                            gameState.State.Message = "The Cat <i>=°ᴥ°=</i> is impressed by your skill. <strong>Let it be known that you are one of the few who make their own path.</strong>";
                            gameState.State.DecisionBabyFinale = ScrambledEggs.BabyFinaleDecision.Jailbreak;
                            break;
                        default:
                            console.warn("dafuq did you do?!");
                            break;
                    }
                    setTimeout(function () {
                        switch(gameState.State.DecisionBabyFinale) {
                            case ScrambledEggs.BabyFinaleDecision.Poopcat:
                                gameState.State.Message = "The Cat <i>=°ᴥ°=</i>'s cries are heard far and wide. Your parents find their way into the room and <strong>laugh</strong>. Victory is yours. The Cat <i>=°ᴥ°=</i> gets a humiliating bath and you grow into a <strong>cunning</strong> young " + (gameState.State.Gender == ScrambledEggs.Gender.Male ? "boy" : "girl") + ".";
                                break;
                            case ScrambledEggs.BabyFinaleDecision.Petcat:
                                gameState.State.Message = "The Cat <i>=°ᴥ°=</i> purrs contently. She recognizes your big heart and decides to be <strong>your ally</strong> from now on. You grow up to be a <strong>gentle</strong> young " + (gameState.State.Gender == ScrambledEggs.Gender.Male ? "boy" : "girl") + ".";
                                break;
                            case ScrambledEggs.BabyFinaleDecision.Doorbang:
                                gameState.State.Message = "Your parents rush in, alarmed by the sound of your <strong>fierce banging</strong>. You learn to never give up, and grow up to be a <strong>strong</strong> young " + (gameState.State.Gender == ScrambledEggs.Gender.Male ? "boy" : "girl") + ".";
                                break;
                            case ScrambledEggs.BabyFinaleDecision.Jailbreak:
                                gameState.State.Message = "Through your hard work you are able to <strong>overcome all challenges</strong> by yourself. You grow up to be a <strong>smart, powerful and independant</strong> young " + (gameState.State.Gender == ScrambledEggs.Gender.Male ? "boy" : "girl") + ".";
                                break;
                            default:
                                console.warn("dafuq did you do?!");
                                break;
                        }
                        me._onUpdate();
                    }, 5000);
                    me._onUpdate();
                });
                finale.find(".continue").click(function () {
                    gameState.State.Phase = ScrambledEggs.GamePhase.YoungAdult;
                    me._onUpdate();
                    $("button.save").click();
                    gameState.State.Message = "Game Saved - You're a young adult now!";
                    $(this).hide();
                });
            };
            BabyFinale.prototype.update = function (gameState, triggerSource) {
                if(gameState.State.DecisionBabyFinale != ScrambledEggs.BabyFinaleDecision.None && gameState.State.Phase == ScrambledEggs.GamePhase.Baby) {
                    $("#babyfinale button").not(".continue").hide();
                    setTimeout(function () {
                        $("#babyfinale button.continue").show();
                    }, 5000);
                }
            };
            return BabyFinale;
        })();
        Modules.BabyFinale = BabyFinale;        
    })(ScrambledEggs.Modules || (ScrambledEggs.Modules = {}));
    var Modules = ScrambledEggs.Modules;
})(ScrambledEggs || (ScrambledEggs = {}));
